# Copyright (C) Kumo inc. and its affiliates.
# Author: Jeff.li lijippy@163.com
# All rights reserved.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program.  If not, see <https:#www.gnu.org/licenses/>.
#
add_subdirectory(utils)

kmcmake_cc_test(
        NAME aggregate_companion_functions_test
        MODULE exec
        SOURCES
        aggregate_companion_adapter_test.cpp
        aggregate_companion_signatures_test.cpp
        dummy_aggregate_function.cpp
        CXXOPTS
        ${KMCMAKE_CXX_OPTIONS}
        -fno-access-control
        LINKS
        pollux::pollux_static
        pollux::pollux_testing_static
        GTest::gtest
        GTest::gtest_main
        ${KMCMAKE_DEPS_LINK}
)

kmcmake_cc_test(
        NAME core_test
        MODULE exec
        SOURCES
        addressable_non_null_value_list_test.cpp
        aggregation_test.cpp
        aggregate_function_registry_test.cpp
        arrow_stream_test.cpp
        assign_unique_id_test.cpp\
        async_connector_test.cpp
        container_row_serde_test.cpp
        custom_join_test.cpp
        enforce_single_row_test.cpp
        exchange_client_test.cpp
        expand_test.cpp
        filter_project_test.cpp
        function_resolution_test.cpp
        hash_bit_range_test.cpp
        hash_join_bridge_test.cpp
        hash_join_test.cpp
        hash_partition_function_test.cpp
        hash_table_test.cpp
        index_lookup_join_test.cpp
        limit_test.cpp
        local_partition_test.cpp
        main.cpp
        mark_distinct_test.cpp
        memory_reclaimer_test.cpp
        merge_join_test.cpp
        merge_test.cpp
        multi_fragment_test.cpp
        nested_loop_join_test.cpp
        order_by_test.cpp
        operator_trace_test.cpp
        output_buffer_manager_test.cpp
        partitioned_output_test.cpp
        plan_node_serde_test.cpp
        plan_node_to_string_test.cpp
        plan_node_to_summary_string_test.cpp
        prefix_sort_test.cpp
        presto_query_runner_timestamp_with_time_zone_transform_test.cpp
        print_plan_with_stats_test.cpp
        probe_operator_state_test.cpp
        trace_util_test.cpp
        round_robin_partition_function_test.cpp
        row_container_test.cpp
        row_number_test.cpp
        scaled_scan_controller_test.cpp
        scale_writer_local_partition_test.cpp
        sort_buffer_test.cpp
        spill_test.cpp
        split_to_string_test.cpp
        sql_test.cpp
        streaming_aggregation_test.cpp
        table_scan_test.cpp
        table_write_test.cpp
        task_listener_test.cpp
        thread_debug_info_test.cpp
        top_n_row_number_test.cpp
        top_n_test.cpp
        unnest_test.cpp
        unordered_stream_reader_test.cpp
        values_test.cpp
        vector_hasher_test.cpp
        window_function_registry_test.cpp
        window_test.cpp
        writer_fuzzer_util_test.cpp
        CXXOPTS
        ${KMCMAKE_CXX_OPTIONS}
        -fno-access-control
        LINKS
        pollux::pollux_static
        pollux::pollux_testing_static
        GTest::gtest
        ${KMCMAKE_DEPS_LINK}
)

kmcmake_cc_test(
        NAME exec_infra_test
        MODULE exec
        SOURCES
        assert_query_builder_test.cpp
        driver_test.cpp
        function_signature_builder_test.cpp
        grouped_execution_test.cpp
        main.cpp
        operator_utils_test.cpp
        plan_builder_test.cpp
        presto_query_runner_test.cpp
        query_assertions_test.cpp
        task_test.cpp
        tree_of_losers_test.cpp
        CXXOPTS
        ${KMCMAKE_CXX_OPTIONS}
        -fno-access-control
        LINKS
        pollux::pollux_static
        pollux::pollux_testing_static
        GTest::gtest
        GTest::gtest_main
        ${KMCMAKE_DEPS_LINK}
)

kmcmake_cc_test(
        NAME join_fuzzer_test
        MODULE exec
        SOURCES
        join_fuzzer_test.cpp
        CXXOPTS
        ${KMCMAKE_CXX_OPTIONS}
        -fno-access-control
        LINKS
        pollux::pollux_static
        pollux::pollux_testing_static
        GTest::gtest
        GTest::gtest_main
        ${KMCMAKE_DEPS_LINK}
)

kmcmake_cc_test(
        NAME memory_arbitration_fuzzer_test
        MODULE exec
        SOURCES
        memory_arbitration_fuzzer_test.cpp
        CXXOPTS
        ${KMCMAKE_CXX_OPTIONS}
        -fno-access-control
        LINKS
        pollux::pollux_static
        pollux::pollux_testing_static
        GTest::gtest
        GTest::gtest_main
        ${KMCMAKE_DEPS_LINK}
)

kmcmake_cc_test(
        NAME exchange_fuzzer_test
        MODULE exec
        SOURCES
        exchange_fuzzer.cpp
        CXXOPTS
        ${KMCMAKE_CXX_OPTIONS}
        -fno-access-control
        LINKS
        pollux::pollux_static
        pollux::pollux_testing_static
        GTest::gtest
        GTest::gtest_main
        ${KMCMAKE_DEPS_LINK}
)

kmcmake_cc_test(
        NAME table_evolution_fuzzer_test
        MODULE exec
        SOURCES
        table_evolution_fuzzer_test.cpp
        CXXOPTS
        ${KMCMAKE_CXX_OPTIONS}
        -fno-access-control
        LINKS
        pollux::pollux_static
        pollux::pollux_testing_static
        GTest::gtest
        GTest::gtest_main
        ${KMCMAKE_DEPS_LINK}
)

kmcmake_cc_test(
        NAME aggregation_runner_test
        MODULE exec
        SOURCES
        aggregation_runner_test.cpp
        CXXOPTS
        ${KMCMAKE_CXX_OPTIONS}
        -fno-access-control
        LINKS
        pollux::pollux_static
        pollux::pollux_testing_static
        GTest::gtest
        GTest::gtest_main
        ${KMCMAKE_DEPS_LINK}
)

kmcmake_cc_test(
        NAME aggregation_runner_test
        MODULE exec
        SOURCES
        aggregation_runner_test.cpp
        CXXOPTS
        ${KMCMAKE_CXX_OPTIONS}
        -fno-access-control
        LINKS
        pollux::pollux_static
        pollux::pollux_testing_static
        GTest::gtest
        GTest::gtest_main
        ${KMCMAKE_DEPS_LINK}
)


kmcmake_cc_library(
        NAMESPACE ${PROJECT_NAME}
        NAME simple_aggregate
        SOURCES
        simple_array_agg_aggregate.cpp
        simple_average_aggregate.cpp
        CXXOPTS
        ${KMCMAKE_CXX_OPTIONS}
        PLINKS
        pollux::pollux_static
        pollux::pollux_testing_static
        GTest::gtest
        ${KMCMAKE_DEPS_LINK}
)

kmcmake_cc_test(
        NAME http_client_test
        MODULE exec
        SOURCES
        cpr_http_client_test.cpp
        CXXOPTS
        ${KMCMAKE_CXX_OPTIONS}
        -fno-access-control
        LINKS
        pollux::pollux_static
        pollux::pollux_testing_static
        GTest::gtest
        GTest::gtest_main
        ${KMCMAKE_DEPS_LINK}
)

kmcmake_cc_test(
        NAME driver_test
        MODULE exec
        SOURCES
        main.cpp
        operator_replacement.cpp
        CXXOPTS
        ${KMCMAKE_CXX_OPTIONS}
        -fno-access-control
        LINKS
        pollux::pollux_static
        pollux::pollux_testing_static
        GTest::gtest
        ${KMCMAKE_DEPS_LINK}
)